<template>
   <div>
    <MyHeader title="购物车案例"></MyHeader>
    <div class="main">
      <MyGoods :goods="goods"></MyGoods>
    </div>
    <MyFooter :goods="goods" @All="isAll"></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
import axios from 'axios'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
    data(){
    return {
      goods:[]
    }
  },
 async created() {
    console.log('执行')
    const rows = await axios.get('https://www.escook.cn/api/cart')
    console.log(rows.data.list);
    this.goods=rows.data.list
  },
  methods:{
    isAll(val){
      this.goods.forEach(item=>item.goods_state=val)
    }
  }
}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>